home *** CD-ROM | disk | FTP | other *** search
- Path: diku.dk!null
- From: null@diku.dk (Niels Ull Jacobsen)
- Newsgroups: comp.lang.c++
- Subject: Re: fast copy
- Date: 23 Feb 1996 16:13:12 GMT
- Organization: Department of Computer Science, U of Copenhagen
- Sender: null@tyr.diku.dk
- Message-ID: <4gkp2o$52j@odin.diku.dk>
- References: <4ftp17$go3@news1.usa.pipeline.com>
- NNTP-Posting-Host: odin.diku.dk
- X-Newsreader: NN version 6.5.0 #13
-
- grantp@usa.pipeline.com(Pete) writes:
-
- >On Feb 12, 1996 22:05:49 in article <fast copy>, 'cbenoit@mail.imaginet.fr
- >(Christophe Benoit)' wrote:
- >
- >
- >>Do you know the best method (run-time performance) to copy a file ?
- >
- >I assume you mean best in terms of time.
- >
- >1. Open the file in binary mode.
- >2. Determine its size
- >3. Allocate a buffer large enough for the entire file.
- >4. Read it in in one fread.
- >5. Open output file and fwrite entire buffer in one whoosh.
- >6. Close both.
-
- Or, alternatively:
- 1. Call the copyfile command of your target OS.
- Most OS's have them (Win16: LZCopy, Win32: CopyFile, ...)
-
-
- >
- >You can beat this using assembler, but such gains are usually
- >insignificant. If the file is too large to fit into one buffer, split
- >it into as large blocks as possible to reduce the number of
- >calls to IO routines.
- >
- >--
- >Pete Grant
- >Kalevi, Inc.
- >Software Engineering & development
- --
- Niels Ull Jacobsen, Dep. of CS, U of Copenhagen (null@diku.dk)
- Roenne Alle 3 st.th, 2860 Soeborg, Denmark, tel. +45 39 66 39 86
-
-